home *** CD-ROM | disk | FTP | other *** search
- Path: su3.in.net!news
- From: mave@in.net (John J. Maver, Jr.)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Random Number Generation
- Date: 16 Feb 1996 01:55:26 GMT
- Organization: INTERNET Indiana
- Message-ID: <692.6619T1254T1752@in.net>
- References: <199602071623.QAA00075@sable.ox.ac.uk> <Pine.OSF.3.91.960207175121.20357B-100000@hai.hiMolde.no>
- <19960207.41F660.11A72@aj050.du.pipex.com> <1100.6613T1273T666@himolde.no>
- Reply-To: mave@in.net
- NNTP-Posting-Host: pm3-08.in.net
- X-Newsreader: THOR 2.22 (Amiga;TCP/IP)
-
-
- I want to generate a randum number, like BASIC allowed you to do, in
- C. I want a function that I can call with the High and Low numbers and then
- have it return a number between them.
-
-
- What I have so far is:
-
- <sb>
-
- float rndnum(float low, float high)
- {
- float num; /*used to temporarily hold a rnd num*/
-
-
- srand=(time(NULL)); /*generate a new seed*/
- num=rand()%1000; /*Try to modify rand()s output to be*/
- num/=100; /*between 0 and 1*/
- num=(num*high)+low; /*Make num fit the specified range*/
-
- return num;
- }
-
- It doesn't quite work. Any hints?
-
- <sb>
-
-
-
-
-
- --John J. Maver, Jr.
-
-